home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / MSDOS / regs3.h < prev    next >
C/C++ Source or Header  |  1979-12-31  |  11KB  |  389 lines

  1. /* $XConsortium: regs3.h,v 1.1 94/03/28 21:13:30 dpw Exp $ */
  2. /* $XFree86: xc/programs/Xserver/hw/xfree86/accel/s3/regs3.h,v 3.8 1994/08/31 04:29:39 dawes Exp $ */
  3. /*
  4.  * regs3.h
  5.  * 
  6.  * Written by Jake Richter Copyright (c) 1989, 1990 Panacea Inc., Londonderry,
  7.  * NH - All Rights Reserved
  8.  * 
  9.  * This code may be freely incorporated in any program without royalty, as long
  10.  * as the copyright notice stays intact.
  11.  * 
  12.  * Additions by Kevin E. Martin (martin@cs.unc.edu)
  13.  * 
  14.  * KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16.  * EVENT SHALL KEVIN E. MARTIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  18.  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  20.  * PERFORMANCE OF THIS SOFTWARE.
  21.  * 
  22.  */
  23.  
  24.  
  25. #ifndef _REGS3_H
  26. #define _REGS3_H
  27.  
  28. /* S3 chipset definitions */
  29.  
  30. /*
  31.  * Modified by Amancio Hasty and Jon Tombs
  32.  * 
  33.  * Id: reg8514.h,v 2.2 1993/06/22 20:54:09 jon Exp jon
  34.  */
  35.  
  36. /*
  37.  * S3 chipset definitions Provided by Jim Nichols <nichols@felix.cmd.usf.edu>
  38.  * intended use: if (S3_801_928_SERIES(chip_id)) { <S3 801 and 928 specific
  39.  * code here> } Note:  The S3 801 and 928 chipsets are very similar.  The
  40.  * primary difference is that the 801 is DRAM based and the 928 is VRAM
  41.  * based.  If you add code for the 801, chances are it will also work fine
  42.  * with the 928, so please use S3_801_928_SERIES and have someone with a 928
  43.  * test it. The 801 and the 805 appear to be indistinguishable from each
  44.  * other using just the chip_id byte.  The 805 is the localbus and EISA
  45.  * version of the 801. S3_911_SERIES will match both the 911 and 924 (as well
  46.  * as any future versions of the 911/924 chips, but not the 801 or 928).
  47.  */
  48.  
  49. /*
  50.  * The early 928's have a nasty bug where memory access can alter io registers.
  51.  * By locking them hopefully this won't happen.
  52.  */
  53. #define vgaCRIndex        0x03d4
  54. #define vgaCRReg        0x03d5
  55. #define vgaBase            ((unsigned char far *)0xa0000000L)
  56.  
  57. #define UNLOCK_SYS_REGS        do { \
  58.                    outb(vgaCRIndex, 0x39); \
  59.                    outb(vgaCRReg, 0xa5); } while (0)
  60.  
  61. #define LOCK_SYS_REGS        do { \
  62.                    outb(vgaCRIndex, 0x39); \
  63.                    outb(vgaCRReg, 0x50); } while (0)
  64.  
  65. #define S3_911_ONLY(chip)       (chip==0x81)
  66. #define S3_924_ONLY(chip)       (chip==0x82)
  67. #define S3_911_SERIES(chip)     ((chip&0xf0)==0x80)
  68. #define S3_801_SERIES(chip)     ((chip&0xf0)==0xa0)
  69. #define S3_805_I_SERIES(chip)   (S3_801_SERIES(chip) && ((chip) & 0x08))
  70. #define S3_801_REV_C(chip)      (S3_801_SERIES(chip) && ((chip) & 0x07) >= 2)
  71. #define S3_928_P(chip)          ((chip&0xf0)==0xb0)
  72. #define S3_928_ONLY(chip)       (((chip&0xf0)==0x90)||S3_928_P(chip))
  73. #define S3_928_REV_E(chip)      (S3_928_ONLY(chip) && ((chip) & 0x0F) >= 4)
  74. #define S3_801_928_SERIES(chip) (S3_801_SERIES(chip)||S3_928_ONLY(chip)||S3_x64_SERIES(chip))
  75. #define S3_8XX_9XX_SERIES(chip) (S3_911_SERIES(chip)||S3_801_928_SERIES(chip))
  76. #define S3_864_SERIES(chip)     ((chip&0xf0)==0xc0)
  77. #define S3_964_SERIES(chip)     ((chip&0xf0)==0xd0)
  78. #define S3_x64_SERIES(chip)    (S3_864_SERIES(chip) || S3_964_SERIES(chip))
  79. #define S3_928_SERIES(chip)     (((chip&0xf0)==0x90)||S3_928_P(chip)||S3_x64_SERIES(chip)) /* hack for 864/964 looking like 928 */
  80. #define S3_ANY_SERIES(chip)     (S3_8XX_9XX_SERIES(chip) || S3_x64_SERIES(chip))
  81.  
  82. /* VESA Approved Register Definitions */
  83. #define    DAC_MASK    0x03c6
  84. #define    DAC_R_INDEX    0x03c7
  85. #define    DAC_W_INDEX    0x03c8
  86. #define    DAC_DATA    0x03c9
  87.  
  88. #define    DISP_STAT    0x02e8
  89. #define    H_TOTAL        0x02e8
  90. #define    H_DISP        0x06e8
  91. #define    H_SYNC_STRT    0x0ae8
  92. #define    H_SYNC_WID    0x0ee8
  93. #define    V_TOTAL        0x12e8
  94. #define    V_DISP        0x16e8
  95. #define    V_SYNC_STRT    0x1ae8
  96. #define    V_SYNC_WID    0x1ee8
  97. #define    DISP_CNTL    0x22e8
  98. #define    ADVFUNC_CNTL    0x4ae8
  99. #define    SUBSYS_STAT    0x42e8
  100. #define    SUBSYS_CNTL    0x42e8
  101. #define    ROM_PAGE_SEL    0x46e8
  102. #define    CUR_Y        0x82e8
  103. #define    CUR_X        0x86e8
  104. #define    DESTY_AXSTP    0x8ae8
  105. #define    DESTX_DIASTP    0x8ee8
  106. #define    ERR_TERM    0x92e8
  107. #define    MAJ_AXIS_PCNT    0x96e8
  108. #define    GP_STAT        0x9ae8
  109. #define    CMD        0x9ae8
  110. #define    SHORT_STROKE    0x9ee8
  111. #define    BKGD_COLOR    0xa2e8
  112. #define    FRGD_COLOR    0xa6e8
  113. #define    WRT_MASK    0xaae8
  114. #define    RD_MASK        0xaee8
  115. #define    COLOR_CMP    0xb2e8
  116. #define    BKGD_MIX    0xb6e8
  117. #define    FRGD_MIX    0xbae8
  118. #define    MULTIFUNC_CNTL    0xbee8
  119. #define    PIX_TRANS    0xe2e8
  120. #define    PIX_TRANS_EXT    0xe2ea
  121. #define    MIN_AXIS_PCNT    0x0000
  122. #define    SCISSORS_T    0x1000
  123. #define    SCISSORS_L    0x2000
  124. #define    SCISSORS_B    0x3000
  125. #define    SCISSORS_R    0x4000
  126. #define    MEM_CNTL    0x5000
  127. #define    PATTERN_L    0x8000
  128. #define    PATTERN_H    0x9000
  129. #define    PIX_CNTL    0xa000
  130. #define    MULT_MISC2    0xd000
  131. #define    MULT_MISC    0xe000
  132. #define    READ_SEL    0xf000
  133.  
  134.  
  135. /* Display Status Bit Fields */
  136. #define    HORTOG        0x0004
  137. #define    VBLANK        0x0002
  138. #define    SENSE        0x0001
  139.  
  140. /* Horizontal Sync Width Bit Field */
  141. #define HSYNCPOL_NEG    0x0020
  142. #define    HSYNCPOL_POS    0x0000
  143.  
  144. /* Vertical Sync Width Bit Field */
  145. #define    VSYNCPOL_NEG    0x0020
  146. #define    VSYNCPOL_POS    0x0000
  147.  
  148. /* Display Control Bit Field */
  149. #define    DISPEN_NC    0x0000
  150. #define    DISPEN_DISAB    0x0040
  151. #define    DISPEN_ENAB    0x0020
  152. #define    INTERLACE    0x0010
  153. #define    DBLSCAN        0x0008
  154. #define    MEMCFG_2    0x0000
  155. #define    MEMCFG_4    0x0002
  156. #define    MEMCFG_6    0x0004
  157. #define    MEMCFG_8    0x0006
  158. #define    ODDBNKENAB    0x0001
  159.  
  160. /* Subsystem Status Register */
  161. #define    _8PLANE        0x0080
  162. #define    MONITORID_8503    0x0050
  163. #define    MONITORID_8507    0x0010
  164. #define    MONITORID_8512    0x0060
  165. #define    MONITORID_8513    0x0060
  166. #define    MONITORID_8514    0x0020
  167. #define    MONITORID_NONE    0x0070
  168. #define    MONITORID_MASK    0x0070
  169. #define    GPIDLE        0x0008
  170. #define    INVALIDIO    0x0004
  171. #define    PICKFLAG    0x0002
  172. #define    VBLNKFLG    0x0001
  173.  
  174. /* Subsystem Control Register */
  175. #define    GPCTRL_NC    0x0000
  176. #define    GPCTRL_ENAB    0x4000
  177. #define    GPCTRL_RESET    0x8000
  178. #define CHPTEST_NC    0x0000
  179. #define CHPTEST_NORMAL    0x1000
  180. #define CHPTEST_ENAB    0x2000
  181. #define    IGPIDLE        0x0800
  182. #define    IINVALIDIO    0x0400
  183. #define    IPICKFLAG    0x0200
  184. #define    IVBLNKFLG    0x0100
  185. #define    RGPIDLE        0x0008
  186. #define    RINVALIDIO    0x0004
  187. #define    RPICKFLAG    0x0002
  188. #define    RVBLNKFLG    0x0001
  189.  
  190. /* Current X, Y & Dest X, Y Mask */
  191. #define    COORD_MASK    0x07ff
  192.  
  193. #ifdef CLKSEL
  194. #undef CLKSEL
  195. #endif
  196.  
  197. /* Advanced Function Control Regsiter */
  198. #define    CLKSEL        0x0004
  199. #define    DISABPASSTHRU    0x0001
  200.  
  201. /* Graphics Processor Status Register */
  202. #define    GPBUSY        0x0200
  203. #define    DATDRDY        0x0100
  204.  
  205. /* Command Register */
  206. #define    CMD_NOP        0x0000
  207. #define    CMD_LINE    0x2000
  208. #define    CMD_RECT    0x4000
  209. #define    CMD_RECTV1    0x6000
  210. #define    CMD_RECTV2    0x8000
  211. #define    CMD_LINEAF    0xa000
  212. #define    CMD_BITBLT    0xc000
  213. #define    CMD_OP_MSK    0xf000
  214. #define    BYTSEQ        0x1000
  215. #define    _16BIT        0x0200
  216. #define    PCDATA        0x0100
  217. #define    INC_Y        0x0080
  218. #define    YMAJAXIS    0x0040
  219. #define    INC_X        0x0020
  220. #define    DRAW        0x0010
  221. #define    LINETYPE    0x0008
  222. #define    LASTPIX        0x0004
  223. #define    PLANAR        0x0002
  224. #define    WRTDATA        0x0001
  225.  
  226. /*
  227.  * Short Stroke Vector Transfer Register (The angular Defs also apply to the
  228.  * Command Register
  229.  */
  230. #define    VECDIR_000    0x0000
  231. #define    VECDIR_045    0x0020
  232. #define    VECDIR_090    0x0040
  233. #define    VECDIR_135    0x0060
  234. #define    VECDIR_180    0x0080
  235. #define    VECDIR_225    0x00a0
  236. #define    VECDIR_270    0x00c0
  237. #define    VECDIR_315    0x00e0
  238. #define    SSVDRAW        0x0010
  239.  
  240. /* Background Mix Register */
  241. #define    BSS_BKGDCOL    0x0000
  242. #define    BSS_FRGDCOL    0x0020
  243. #define    BSS_PCDATA    0x0040
  244. #define    BSS_BITBLT    0x0060
  245.  
  246. /* Foreground Mix Register */
  247. #define    FSS_BKGDCOL    0x0000
  248. #define    FSS_FRGDCOL    0x0020
  249. #define    FSS_PCDATA    0x0040
  250. #define    FSS_BITBLT    0x0060
  251.  
  252. /* The Mixes */
  253. #define    MIX_MASK            0x001f
  254.  
  255. #define    MIX_NOT_DST            0x0000
  256. #define    MIX_0                0x0001
  257. #define    MIX_1                0x0002
  258. #define    MIX_DST                0x0003
  259. #define    MIX_NOT_SRC            0x0004
  260. #define    MIX_XOR                0x0005
  261. #define    MIX_XNOR            0x0006
  262. #define    MIX_SRC                0x0007
  263. #define    MIX_NAND            0x0008
  264. #define    MIX_NOT_SRC_OR_DST        0x0009
  265. #define    MIX_SRC_OR_NOT_DST        0x000a
  266. #define    MIX_OR                0x000b
  267. #define    MIX_AND                0x000c
  268. #define    MIX_SRC_AND_NOT_DST        0x000d
  269. #define    MIX_NOT_SRC_AND_DST        0x000e
  270. #define    MIX_NOR                0x000f
  271.  
  272. #define    MIX_MIN                0x0010
  273. #define    MIX_DST_MINUS_SRC        0x0011
  274. #define    MIX_SRC_MINUS_DST        0x0012
  275. #define    MIX_PLUS            0x0013
  276. #define    MIX_MAX                0x0014
  277. #define    MIX_HALF__DST_MINUS_SRC        0x0015
  278. #define    MIX_HALF__SRC_MINUS_DST        0x0016
  279. #define    MIX_AVERAGE            0x0017
  280. #define    MIX_DST_MINUS_SRC_SAT        0x0018
  281. #define    MIX_SRC_MINUS_DST_SAT        0x001a
  282. #define    MIX_HALF__DST_MINUS_SRC_SAT    0x001c
  283. #define    MIX_HALF__SRC_MINUS_DST_SAT    0x001e
  284. #define    MIX_AVERAGE_SAT            0x001f
  285.  
  286. /* Memory Control Register */
  287. #define    BUFSWP        0x0010
  288. #define    VRTCFG_2    0x0000
  289. #define    VRTCFG_4    0x0004
  290. #define    VRTCFG_6    0x0008
  291. #define    VRTCFG_8    0x000C
  292. #define    HORCFG_4    0x0000
  293. #define    HORCFG_5    0x0001
  294. #define    HORCFG_8    0x0002
  295. #define    HORCFG_10    0x0003
  296.  
  297. /* Pixel Control Register */
  298. #define    MIXSEL_FRGDMIX    0x0000
  299. #define    MIXSEL_PATT    0x0040
  300. #define    MIXSEL_EXPPC    0x0080
  301. #define    MIXSEL_EXPBLT    0x00c0
  302. #define COLCMPOP_F    0x0000
  303. #define COLCMPOP_T    0x0008
  304. #define COLCMPOP_GE    0x0010
  305. #define COLCMPOP_LT    0x0018
  306. #define COLCMPOP_NE    0x0020
  307. #define COLCMPOP_EQ    0x0028
  308. #define COLCMPOP_LE    0x0030
  309. #define COLCMPOP_GT    0x0038
  310. #define    PLANEMODE    0x0004
  311.  
  312.   typedef struct {
  313.      unsigned char r, g, b;
  314.   }
  315. LUTENTRY;
  316.  
  317. #ifdef S3_MMIO 
  318. # define DISABLE_MMIO   \
  319.       { unsigned char tmp; \
  320.       outb(vgaCRIndex, 0x53); \
  321.       tmp = inb(vgaCRReg); \
  322.       outb(vgaCRReg, tmp & 0xEF); }
  323. # define ENABLE_MMIO   \
  324.       { unsigned char tmp; \
  325.       outb(vgaCRIndex, 0x53); \
  326.       tmp = inb(vgaCRReg); \
  327.       outb(vgaCRReg, tmp | 0x10); }
  328. #else
  329. # define DISABLE_MMIO /**/
  330. # define ENABLE_MMIO /**/
  331. #endif
  332.       
  333. /* Wait until "v" queue entries are free
  334. */
  335. #define    WaitQueue(v)    do {\
  336.                 long ll = 100000;\
  337.                 while (inb(GP_STAT) & (0x0100 >> (v))) {\
  338.                     if (--ll <= 0)\
  339.                         die ();\
  340.                     sys_poll (99);\
  341.                 }\
  342.             } while(0)
  343.  
  344. /* x64: Wait until "v" queue entries are free, v>8 for 864/964
  345. */
  346. #define    WaitQueue16(v)    do {\
  347.                 long ll = 100000;\
  348.                 while (inw(GP_STAT) & (0x8000 >> (v-9))) {\
  349.                     if (--ll <= 0)\
  350.                         die ();\
  351.                     sys_poll (98);\
  352.                 }\
  353.             } while(0)
  354.  
  355. /* Wait until GP is idle and queue is empty */
  356. /* x64: bits 15-11 are reserved in 928 and should be zero,
  357.         for 864/964 these are FIFO-STATUS bits 9-13 */
  358. #define    WaitIdleEmpty() \
  359.    do { int fx86=(S3_x64_SERIES(s3ChipId)?0xF800:0); while (inw(GP_STAT) & (GPBUSY | 1 | fx86)); } while (0)
  360.  
  361. /* Wait until GP is idle */
  362. #define WaitIdle() do { while (inw(GP_STAT) & GPBUSY) \
  363.                 sys_poll (97); } while(0)
  364.  
  365. /* This one from s3.h */
  366. #if defined(S3_MMIO) && (defined(__STDC__) || defined(__GNUC__))
  367. # define S3_OUTW(p,n) *(volatile unsigned short *)((char *)vgaBase+(p)) = \
  368.             (unsigned short)(n)
  369. #else
  370. # define S3_OUTW(p,n) outw(p, n)
  371. #endif
  372.  
  373. #define    MODE_800    1
  374. #define    MODE_1024    2
  375. #define    MODE_1280    3
  376. #define MODE_1152    4    /* 801/805 C-step, 928 E-step */
  377. #define MODE_1600    5    /* 928 E-step */
  378.  
  379. #ifndef NULL
  380. #define NULL    0
  381. #endif
  382.  
  383. #define RGB8_PSEUDO      (-1)
  384. #define RGB16_565         0
  385. #define RGB16_555         1
  386. #define RGB32_888         2
  387.  
  388. #endif /* _REGS3_H */
  389.